package com.example.keli.ui.my.commission;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;

import com.example.keli.R;
import com.example.keli.base.BaseActivity;
import com.example.keli.base.app.C;
import com.flyco.roundview.RoundTextView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.OnClick;
import com.example.keli.api.http.api.BaseResponse;

/**
 * description 提成方式
 * created by jerry on 2019/3/18.
 */
public class CommissionTypeActivity extends BaseActivity {

    @BindView(R.id.rb_alipay)
    RadioButton rbAlipay;
    @BindView(R.id.rb_wechatpay)
    RadioButton rbWechatpay;
    @BindView(R.id.et_count)
    EditText etCount;
    @BindView(R.id.et_name)
    EditText etName;
    @BindView(R.id.tv_next)
    RoundTextView tvNext;

    private String mDishNum;

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onDishSuccess(String event){
        if (C.EVENT.DISH_FINISH.equals(event)){
            finish();
        }
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_commission_type;
    }

    @Override
    protected void bindData() {
        EventBus.getDefault().register(this);
//        setTitle("提现");
        abTitle.setText("提现");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mDishNum = getIntent().getStringExtra("dish_num");
    }

    @OnClick(R.id.tv_next)
    public void onViewClicked() {
        String count = etCount.getText().toString().trim();
        String name = etName.getText().toString().trim();
        if (TextUtils.isEmpty(count)){
            toast("请输入账号");
            return;
        }
        if (TextUtils.isEmpty(name)){
            toast("请输入姓名");
            return;
        }
        startActivity(new Intent(this, DishActivity.class)
                .putExtra("dish_num", mDishNum)
                .putExtra("alipay_count", count)
                .putExtra("alipay_name", name));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
